package com.qfedu.video.controller;


import com.qfedu.video.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/admin")
public class AdminController {


    //多态   封装，继承，多态
    @Autowired
    AdminService adminService;

    @RequestMapping("/showLogin")
    public String showLogin(){
        return "behind/index";
    }

    @RequestMapping("/login")
    @ResponseBody
    public String login( String username, String password, HttpSession session){

        String result = adminService.login(username,password);
        if(result.equals("1")){
            session.setAttribute("userName",username);
        }
        return result;
        /*if(username.equals("admin")&& password.equals("123456")){
            return "1";
        }
        return "0";*/
    }
}
